package com.gopay.solution.dao.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.solution.domain.po.SsGpRiskFundConfDtl;

/**
 * 风险金额度设置明细DAO
 * @SsGpRiskFundConfDtlDAOImpl.java
 * @author Ryan
 * @2014年4月18日 下午2:05:27  www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("ssGpRiskFundConfDtlDAO")
public class SsGpRiskFundConfDtlDAOImpl extends SolutionRuleDtlDAOImpl<SsGpRiskFundConfDtl, Serializable> {

    @Override
    public SsGpRiskFundConfDtl getByPk(Serializable id) {
        return find(SsGpRiskFundConfDtl.class,id);
    }

    @Override
    public List<SsGpRiskFundConfDtl> listBySolutionId(long solutionId) {
        String hql ="from SsGpRiskFundConfDtl dtl where dtl.solutionId = :SolutionId order by dtl.sq";
        Map<String,Object> param = new HashMap<String,Object>();
        param.put("SolutionId", solutionId);
        return findByHql(hql, param);
    }

    @Override
    public boolean delBySolutionId(long solutionId) {
        List<SsGpRiskFundConfDtl> dtls = listBySolutionId(solutionId);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

    @Override
    public List<SsGpRiskFundConfDtl> listBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        String hql = "from SsGpRiskFundConfDtl dtl where dtl.solutionId = :SolutionId and dtl.gopayIntTxnCd = :GopayIntTxnCd order by dtl.sq";
        Map<String,Object> params = new HashMap<String,Object>();
        params.put("SolutionId", solutionId);
        params.put("GopayIntTxnCd", intTxnCd);
        
        return findByHql(hql, params);
    }

    @Override
    public boolean delBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        List<SsGpRiskFundConfDtl> dtls = listBySoluIdAndIntTxnCd(solutionId, intTxnCd);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

   

}
